/**
 * {{&summary}}
 * @method
 * @name {{&className}}#{{&methodName}}
 * @param {object} parameters - method options and parameters
{{#parameters}}
    {{^isSingleton}} * @param {{=<% %>=}}{<%&type%>}<%={{ }}=%> parameters.{{&camelCaseName}} - {{&description}}{{/isSingleton}}
{{/parameters}}
 */
 {{&className}}.prototype.{{&methodName}} = function(parameters){
    if(parameters === undefined) {
        parameters = {};
    }
    {{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} domain = this.domain,  path = '{{&path}}';
    {{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} body = {}, queryParameters = {}, form = {};
    {{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} headers = util.clone(this.headers);

    {{#isSecure}}
        headers = this.setAuthHeaders(headers);
    {{/isSecure}}
    {{#headers}}
        headers['{{&name}}'] = [{{&value}}];
    {{/headers}}

    {{#parameters}}
        {{#isQueryParameter}}
            {{#isSingleton}}
                queryParameters['{{&name}}'] = '{{&singleton}}';
            {{/isSingleton}}
            {{^isSingleton}}
                {{#isPatternType}}
                    Object.keys(parameters).forEach(function(parameterName) {
                        if(new RegExp('{{&pattern}}').test(parameterName)){
                            queryParameters[parameterName] = parameters[parameterName];
                        }
                    });
                {{/isPatternType}}
                {{#default}}
                    /** set default value **/
                    queryParameters['{{&name}}'] = {{&default}};
                {{/default}}

                {{^isPatternType}}
                if(parameters['{{&camelCaseName}}'] !== undefined){
                    queryParameters['{{&name}}'] = parameters['{{&camelCaseName}}'];
                }
                {{/isPatternType}}
            {{/isSingleton}}
        {{/isQueryParameter}}
        
        {{#isPathParameter}}
            path = path.replace('{{=<% %>=}}{<%&name%>}<%={{ }}=%>', parameters['{{&camelCaseName}}']);
        {{/isPathParameter}}
        
        {{#isHeaderParameter}}
            {{#isSingleton}}
                headers['{{&name}}'] = '{{&singleton}}';
            {{/isSingleton}}
            {{^isSingleton}}
                if(parameters['{{&camelCaseName}}'] !== undefined){
                    headers['{{&name}}'] = parameters['{{&camelCaseName}}'];
                }
            {{/isSingleton}}
        {{/isHeaderParameter}}
        
        {{#isBodyParameter}}
            if(parameters['{{&camelCaseName}}'] !== undefined){
                body = parameters['{{&camelCaseName}}'];
            }
        {{/isBodyParameter}}

         {{#isFormParameter}}
            {{#isSingleton}}
                form['{{&name}}'] = '{{&singleton}}';
            {{/isSingleton}}
            {{^isSingleton}}
                if(parameters['{{&camelCaseName}}'] !== undefined){
                    form['{{&name}}'] = parameters['{{&camelCaseName}}'];
                }
            {{/isSingleton}}
        {{/isFormParameter}}

        {{#required}}
        if(parameters['{{&camelCaseName}}'] === undefined)
            throw new Error('Missing required {{&paramType}} parameter: {{&camelCaseName}}');
        {{/required}}
 
    {{/parameters}}
    queryParameters = mergeQueryParams(parameters, queryParameters);

    return request('{{method}}', domain + path, parameters, body, headers, queryParameters, form);
 };
